<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>    
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>상품상세정보</title>
<link href="/Jangdolbaeng2/css/customer/common1.css" rel="stylesheet">
<link href="/Jangdolbaeng2/css/bootstrap.min.css" rel="stylesheet">
<link href="/Jangdolbaeng2/css/customer/common.css" rel="stylesheet">
<script src="/Jangdolbaeng2/js/jquery-1.11.1.js"></script>
<script src="/Jangdolbaeng2/js/bootstrap.min.js"></script>
<script type="text/javascript">
function deletefunc(productseq, shopseq)
{
	if(confirm('삭제하시겠습니까?'))
	{
		location.href='deleteProduct.action?productVO.shop_seq=' + shopseq 
			+ '&productVO.product_seq=' + productseq;
	}
}

function deleteOutput(json)
{
	alert(json.deleteCheck);	
}


function formCheck()
{
	var product_image1 = $('#product_image1').val();
	var product_price = $('#product_price').val();
	var product_stock = $('#product_stock').val();
	var product_info1 = $('#product_info1').val();

	if(product_price == 0 || product_price == '')
	{
		alert('가격을 입력하시오');
		return false;
	}
	
	if(isNaN(product_price))
	{
		alert('숫자를 입력하시오');
		return false;
	}
	
	if(product_stock == 0 || product_stock == '')
	{
		alert('재고량을 입력하시오');
		return false;
	}
	
	if(product_info1 == 0 || product_info1 == '')
	{
		alert('상품정보를 입력하시오');
		return false;
	}

	if(product_image1 == '')
	{
		alert('상품사진을 다시 입력하시오')
		return false;
	}
	
	return true;	
}


function returnfunc(shopseq)
{
	location.href='shopProduct.action?productVO.shop_seq=' + shopseq;
}

</script>
</head>
<body>
<div id="header">
<%@ include file="adminHeader.jsp" %>
</div>

<div class="container">
	<h3 align="center" style="margin-top: 50px; margin-bottom: 20px;"><span class="glyphicon glyphicon-tags"></span> <span style="font-family: anew">상품수정</span></h3>
	
	<div id="div1" align="center">
		<s:form name="productVO" action="updateProduct" method="post" theme="simple" 
		enctype="multipart/form-data" onsubmit="return formCheck()">
		<table class="table table table-striped table-hover table-bordered" style="text-align: center;  width: 600px;">	
			<s:hidden name="productVO.product_seq" value="%{productVO.product_seq}" />
			<s:hidden name="productVO.product_name" value="%{productVO.product_name}" />
			<s:hidden name="productVO.product_category" value="%{productVO.product_category}" />
			<s:hidden name="productVO.shop_seq" value="%{productVO.shop_seq}" />
			
			<tr>
				<td class="success" style="font-weight: bold">상품번호</td>
				<td><s:property value="productVO.product_seq" /></td>
			</tr>
			<tr>
				<td class="success" style="font-weight: bold">제품</td>
				<td colspan="2"><s:property value="productVO.product_name" /></td>
			</tr>
			<tr>
				<td class="success" style="font-weight: bold">가격</td>
				<td><s:textfield size="7" name="productVO.product_price" id="product_price" value="%{productVO.product_price}" theme="simple" /></td>
			</tr>
			<tr>
				<td class="success" style="font-weight: bold">상품사진1</td>
				<td align="center">
				<s:if test="productVO.product_image1 == ''">
					<s:file id="product_image1" name="uploads" size="30" />
				</s:if>
				<s:if test="productVO.product_image1 != ''">
					${photo1}	
					<img width="400" height="200" src="data:image/jpeg;base64, ${productVO.product_image1}">
					<s:file id="product_image1" name="uploads" size="30" />
				</s:if>
				</td>
			</tr>
			<tr>
				<td class="success" style="font-weight: bold">상품사진2</td>
				<td align="center">
				<s:if test="productVO.product_image2 == ''">
					<s:file id="product_image2" name="uploads" size="30" />
				</s:if>
				<s:if test="productVO.product_image2 != ''">
					${photo2}	
					<img width="400" height="200" src="data:image/jpeg;base64, ${productVO.product_image2}">
					<s:file id="product_image2" name="uploads" size="30" />
				</s:if>
				</td>
			</tr>
			<tr>
				<td class="success" style="font-weight: bold">상품정보1</td>
				<td><s:textarea name="productVO.product_info1" id="product_info1" value="%{productVO.product_info1}" cssStyle="width:400px;height:250px;resize:none" theme="simple" /></td>
			</tr>
			<tr>
				<td class="success" style="font-weight: bold">상품정보1</td>
				<td><s:textarea name="productVO.product_info2" id="product_info2" value="%{productVO.product_info2}" cssStyle="width:400px;height:250px;resize:none" theme="simple" /></td>
			</tr>
			<tr>
				<td class="success" style="font-weight: bold">상품등록날짜</td>
				<td colspan="2"><s:property value="productVO.inputdate" /></td>
			</tr>
		</table>
		<button type="submit" class="btn btn-default" style="width: 200px; background-color: #62943D;"><span style="color: white;">수정</span></button>	
		<button type="button" class="btn btn-default" style="width: 200px; background-color: #62943D;" onclick="deletefunc(<s:property value="%{productVO.product_seq}" />, <s:property value="productVO.shop_seq" />)"><span style="color: white;">삭제</span></button>
		<button type="button" class="btn btn-default" style="width: 200px; background-color: #62943D;" onclick="returnfunc(<s:property value="%{productVO.shop_seq}" />)"><span style="color: white;">돌아가기</span></button>
		</s:form>
	</div>
</div><!-- end of container -->




</body>
</html>